<template>
	<view class="detail-wrap ">
		<mescroll-body ref="mescrollRef" :up="upOption" :down="downOption" @init="mescrollInit" @down="downCallback"
			@up="upCallback">
			<shopro-login-modal></shopro-login-modal>
			<public-module></public-module>
			<!-- 标题栏 -->
			<view class="nav-box">
				<view class="state-hack"></view>
				<!-- <view :style="{ height: navbarHeight + 'px' }" style="padding-left: 30upx;">
				<view hover-class="back-hover" class="back-box u-m-x-30 u-flex u-row-center u-col-center"
					@tap="jump('/pages/personal/personal')">
					<u-icon :name="backIconName" color="#fff"></u-icon>
				</view>
			</view> -->
			</view>
			<!-- 缺省页 -->
			<!-- <shopro-empty v-if="showEmpty" :image="$IMG_URL + '/imgs/empty/empty_goods_null.png'" :tipText="showEmptyText"
			btnText="返回上一页" @click="jump('/pages/personal/personal')"></shopro-empty> -->
			<view class="detail_box">
				<view class="detail-content">
					<!-- 轮播 -->
					<u-swiper :height="750" borderRadius="0" :list="goodsInfo.has_one_group.has_one_goods.thumb_url"
						indicator-pos="bottomRight" mode="number" :interval="3000" @click="onGoodsSwiper"></u-swiper>
					<!-- 价格卡片组 -->
					<sh-price-card v-if="goodsInfo.id" :detail="goodsInfo" :type="detailType"
						@change="getActivityRules">
					</sh-price-card>

					<!-- 标题 -->
					<view class="u-m-b-10 title-box u-p-20 u-skeleton-fillet">
						<view class="goods-title u-m-b-10 u-ellipsis-2">{{ goodsInfo.has_one_group.title }}
						</view>
						<!-- <view class="sub-title u-ellipsis-2">{{ goodsInfo.subtitle }}</view> -->
						<view class="butie-box">
							<text class="butie-left">{{ goodsInfo.user_subsidy }}人已领取补贴</text>
							<text class="butie-right">成团:<text
									style="color: #FF5E24;">{{goodsInfo.has_one_group.has_many_team_count}}次</text></text>
						</view>
					</view>
					<!-- 红包组件 -->
					<view style="display: flex;
	justify-content: space-between;
	align-items: center;
	position: relative;
	background-repeat: no-repeat;
	background-size: 100% 100%;
	margin: 0 auto;
	width: 700upx;
	height: 147upx;
	padding: 40upx 29upx;">
						<image src="../../../static/images/index/red-packback.png"
							style="width: 100%; height: 100%; position: absolute; z-index: -1; left: 0; right: 0;">
						</image>
						<view class="red-left">
							<view class="price-box">现金补贴￥{{ goodsInfo.has_one_group.subsidy }}</view>
							<view class="piper-count">{{goodsInfo.team_str}}</view>
						</view>
						<view class="red-right">
							<view class="count">{{goodsInfo.has_one_level.member_num}}人成团</view>
							<view v-if="goodsInfo.status == 1" class="butie" @click="goPay">领取补贴</view>
							<view v-else-if="goodsInfo.status == 2" class="butie">已经成团</view>
						</view>
					</view>
					<!-- <view class="red-packback">
					<image src="../../../static/images/index/red-packback.png"
						style="width: 100%; height: 100%; position: absolute; z-index: -1; left: 0; right: 0;"></image>
					<view class="red-left">
						<view class="price-box">现金补贴￥{{ goodsInfo.has_one_group.subsidy }}</view>
						<view class="piper-count">{{goodsInfo.team_str}}</view>
					</view>
					<view class="red-right">
						<view class="count">{{goodsInfo.has_one_level.member_num}}人成团</view>
						<view v-if="goodsInfo.status == 1" class="butie" @click="goPay">领取补贴</view>
						<view v-else-if="goodsInfo.status == 2" class="butie">已经成团</view>
					</view>
				</view> -->
					<block v-if="goodsInfo.status == 1">
						<!-- 拼团组件 -->
						<view class="ptuan-group" v-show="goodsInfo.is_team != 0" @click="goPingtuan()">
							<text
								style="font-size: 33upx; color: #010101;  font-weight: bold;">{{goodsInfo.status == 1? '拼团中': goodsInfo.status == 2 ? '拼团成功': '拼团失败'}}</text>
							<view class="img-group-box">
								<image v-for="(item,index) in goodsInfo.has_many_success_member" :key="index"
									:src="has_one_member.avatar_image"></image>
								<!-- <image src="../../../static/images/index/hot.png" ></image>
							<image src="../../../static/images/index/hot.png" ></image> -->
							</view>
							<view class="ptuan-tip" v-if="goodsInfo.status != 2">
								{{goodsInfo.has_many_success_member_count}}人已领取补贴，还差{{goodsInfo.yes_team}}人成团
							</view>
						</view>
						<view style="width: 750upx;height: 1upx;background: #EEEEEE; margin-top: 33upx;"></view>
						<!-- 拼团列表 -->
						<view class="goods-list-box" v-if=" goodsInfo.has_many_success_member.length > 0">
							<view class="goods-list-contnet">
								<view class="list-content-item"
									v-for="(item, index) in goodsInfo.has_many_success_member" :key="index">
									<view class="style1">
										<view class="left">
											<image :src="item.has_one_member.avatar"
												style="width: 56upx;height: 56upx;border-radius: 50%;">
											</image>
											<text
												style="margin-left: 16upx; font-size: 27upx;">{{item.has_one_member.nickname}}</text>
										</view>
										<view v-if="goodsInfo.status == 1" class="right">
											￥{{item.member_id === userInfo.uid ? item.price : '成团后公布'}}</view>
										<view v-if="goodsInfo.status == 2" class="right">￥{{item.price}}</view>
									</view>
									<view class="style2" v-show="item.member_id === userInfo.uid">
										更多内容拼团成功后公布
									</view>
								</view>
							</view>
						</view>

					</block>
					<!-- 规格选择 -->
					<view class="sku-box" @tap="goPay()"
						v-if="activityRules.status !== 'waiting' && checkActivity(goodsInfo.activity_type, 'groupon') && goodsInfo.is_sku">
						<view class="x-bc">
							<view class="u-flex">
								<text class="title">规格</text>
								<text class="tip">{{ currentSkuText || '请选择规格' }}</text>
							</view>
							<text class="cuIcon-right"></text>
						</view>
					</view>

					<!-- 服务 -->
					<sh-serve v-if="goodsInfo.service && goodsInfo.service.length" v-model="showServe"
						:serveList="goodsInfo.service"></sh-serve>
					<!-- 拼团玩法和说明 -->
					<view class="pingtuan-tipsbox">
						<view class="tipsbox-title">
							<view class="left">拼团玩法</view>
							<view class="right">详细规则</view>
						</view>
						<view class="line-box">
							<view class="line-item">
								<view class="number">1</view>
								<view class="">选择商品</view>
							</view>
							<view class="line-item">
								<view class="number">2</view>
								<view class="">领取拼团补贴</view>
							</view>
							<view class="line-item">
								<view class="number">3</view>
								<view class="">人满开奖</view>
							</view>
							<view class="line-item">
								<view class="number">4</view>
								<view class="">拼中商品</view>
							</view>
						</view>
						<view class="tipsbox-line"
							style="margin-top: 30upx; width: 750upx;height: 1upx;background: #EEEEEE;">

						</view>
						<view class="shuoming-box">
							<image src="../../../static/images/index/zhuyi2.png" style="width: 30upx; height: 30upx;">
							</image>
							<view style="color: #454444; font-size: 22upx; margin-left: 20upx;">
								活动商品一经售出不支持退货退款。<br /> 参与活动前请您仔细阅读<text style="color: #FF4F10;">《拼团活动规则》</text>
							</view>
						</view>
					</view>
					<!-- end -->
					<!-- 选项卡 -->
					<!-- <view class="tab-box u-flex">
					<view class="tab-item u-flex-col u-row-center u-col-center" @tap="onTab(tab.id)"
						v-for="tab in tabList" :key="tab.id">
						<view class="tab-title">
							{{ tab.title }}
							<text v-if="tab.id == 'tab2'" class="comment-num">({{ commentNum }})</text>
						</view>
						<text class="tab-line" :class="{ 'line-active': tabCurrent === tab.id }"></text>
					</view>
				</view> -->
					<!-- 选项卡内容 -->
					<view class="tab-detail u-p-20 u-m-b-10">
						<!-- 详情富文本 -->
						<view class="rich-box " v-if="tabCurrent === 'tab0'">
							<u-parse :html="goodsInfo.has_one_group.has_one_goods.content"></u-parse>
						</view>
						<!-- 参数 -->
						<view class="goods-size" v-if="tabCurrent === 'tab1'">
							<view class="table-box" v-if="goodsInfo.params && goodsInfo.params.length">
								<view class="t-tr u-flex" v-for="t in goodsInfo.params" :key="t.title">
									<view class="t-head u-flex">{{ t.title }}</view>
									<view class="t-detail">{{ t.content }}</view>
								</view>
							</view>
						</view>
						<!-- 评价 -->
						<view class="goods-comment" v-if="tabCurrent === 'tab2'">
							<block v-for="comment in commentList" :key="comment.id">
								<sh-comment :comment="comment"></sh-comment>
							</block>
							<!-- <shopro-empty v-show="!commentList.length" marginTop="20rpx"
							:image="$IMG_URL + '/imgs/empty/comment_empty.png'" tipText="暂无评价~"></shopro-empty> -->
							<view class="more-box u-flex u-row-center u-col-center" v-show="commentList.length >= 3">
								<button class="u-reset-button more-btn u-flex u-row-center u-col-center"
									@tap="jump('/pages/goods/comment/comment-list', { goodsId: goodsInfo.id })">
									查看全部
									<u-icon name="arrow-right" size="28" color="#d5a65a"></u-icon>
								</button>
							</view>
						</view>
					</view>

					<!-- 商品foot -->
					<view class="tabbar-foot safe-area-inset-bottom" v-if="goodsInfo.id">
						<view class="detail-foot_box safe-area-inset-bottom  u-flex">
							<!-- foot左侧 -->
							<view class="left u-flex">
								<!-- 积分foot -->
								<view class="tools-item u-flex-col u-row-center u-col-center"
									@tap="$Router.pushTab({path: '/pages/index/index'});">
									<image class="tool-img shopro-selector-circular"
										src="../../../static/images/index/index.png" mode=""></image>
									<text class="tool-title shopro-selector-rect">首页</text>
								</view>
								<view class="tools-item u-flex-col u-row-center u-col-center"
									@tap="jump('/pages/prefile/my-collage/my-collage')">
									<image class="tool-img shopro-selector-circular"
										src="../../../static/images/index/ptuan.png" mode=""></image>
									<text class="tool-title shopro-selector-rect">我的拼团</text>
								</view>
								<!-- 非积分foot -->
								<block v-if="detailType !== 'score'">
									<!-- <view class="tools-item u-flex-col u-row-center u-col-center"
									@tap="onFavorite(goodsInfo.id)">
									<image class="tool-img"
										:src="Boolean(goodsInfo.favorite) ? $IMG_URL + '/imgs/detail/detail_favorite_end.png' : $IMG_URL + '/imgs/detail/detail_favorite.png'"
										mode=""></image>
									<text class="tool-title">收藏</text>
								</view> -->
									<!-- <view class="tools-item u-flex-col u-row-center u-col-center" @tap="onShare">
									<image class="tool-img" :src="$IMG_URL + '/imgs/share/share.png'" mode=""></image>
									<text class="tool-title">分享</text>
								</view> -->
								</block>
							</view>
							<!-- foot右侧 -->
							<view class="detail-right">
								<!-- 积分按钮 -->
								<view class="detail-btn-box" v-if="detailType === 'score'"><button
										class="u-reset-button  score-btn" @tap="goPay">立即兑换</button></view>
								<view v-if="detailType !== 'score'">
									<!-- 正常按钮 -->
									<view class="detail-btn-box u-flex u-row-around" v-if="!goodsInfo.activity_type">
										<!-- <button class=" u-reset-button tool-btn add-btn" @tap="addCart">加入购物车</button> -->
										<button v-show="goodsInfo.is_team === 0 && goodsInfo.status === 1"
											class=" u-reset-button tool-btn pay-btn" @tap="goPay">领取补贴</button>
										<button v-show="goodsInfo.is_team != 0 && goodsInfo.status === 1"
											class=" u-reset-button tool-btn pay-btn">拼团中{{goodsInfo.has_many_success_member_count}}/{{goodsInfo.has_one_level.member_num}}</button>
										<button v-show="goodsInfo.status === 2"
											class=" u-reset-button tool-btn pay-btn">已成团</button>
									</view>
									<!-- 活动按钮 -->
									<view class="detail-btn-box u-row-around"
										v-if="activityRules.status && goodsInfo.activity_type">
										<button class=" u-reset-button seckilled-btn"
											v-if="activityRules.status !== 'ing'">
											<text v-if="activityRules.status == 'waiting'">暂未开始</text>
											<text v-if="activityRules.status == 'end'">已结束</text>
										</button>
										<block v-else>
											<!-- 活动中，秒杀 -->
											<button class=" u-reset-button  seckill-btn"
												v-if="goodsInfo.activity && goodsInfo.activity.type === 'seckill'"
												@tap="goSeckill">
												立即秒杀
											</button>
											<!-- 活动中，拼团 -->
											<view class="u-flex groupon-btn-box"
												v-if="goodsInfo.activity && goodsInfo.activity.type === 'groupon'">
												<button
													class="tool-btn u-reset-button add-btn u-flex-col u-row-center u-col-center"
													@tap="payGroupon" v-if="goodsInfo.activity.rules.is_alone === '1'">
													<text class="price font-OPPOSANS">￥{{ goodsInfo.price }}</text>
													<text class="price-title">单独购买</text>
												</button>
												<button
													class=" tool-btn u-reset-button groupon-btn u-flex-col u-row-center u-col-center"
													:style="goodsInfo.activity.rules.is_alone === '0' ? 'width:400rpx' : ''"
													@tap="payGroupon('groupon')">
													<text
														class="price font-OPPOSANS">￥{{ goodsInfo.groupon_price }}</text>
													<text class="price-title">我要开团</text>
												</button>
											</view>
										</block>
									</view>
								</view>
							</view>
						</view>
					</view>

					<!-- 规格弹窗 -->
					<!-- <shopro-sku v-if="showSku && goodsInfo.id" v-model="showSku" :goodsInfo="goodsInfo"
					:activityRules="activityRules"
					:buyType="goodsInfo.activity_type == 'seckill' || detailType === 'score' ? 'buy' : buyType"
					 :goodsType="detailType === 'score' ? 'score' : 'goods'"
					 
					@changeType="changeType" @getSkuText="getSkuText"></shopro-sku>
 -->
				</view>
			</view>

			<!-- 登录提示 -->
			<!-- <shopro-login-modal></shopro-login-modal> -->
			<!-- 红包 -->
			<!-- 红包封面 -->
			<view class="rbag_model" v-if="!openrbagmodelshow && rbagmodelshow" @touchmove.prevent.stop>
				<view class="rbag_con hidden">
					<view class="rbag_top">
						<view class="rbag_top_info">
							<image class="rbag_logo" src="/static/icon/logo.jpg" mode=""></image>
							<view class="app_name">恭喜发财</view>
							<view class="rbag_tips">送您一个红包</view>
						</view>
					</view>
					<view class="open_rbag_btn" :animation="openbrnanimation" @click="openbtn()">開</view>
				</view>
				<view class="rbag_con">
					<view class="hide_btn" @click.stop="hidebtn">
						<icon type="cancel" color="#fbd977" size="28" />
					</view>
				</view>
			</view>

			<view class="open_rbag_model" v-if="openrbagmodelshow" @touchmove.prevent.stop>
				<image class="rbag_conbg" src="/static/images/index/openrbag.png"></image>
				<view class="rbag_conbg open_rbag_con">
					<view class="open_title">— 恭喜您获得 —</view>
					<view class="rbag_detail">
						<view class="open_money">
							<countup :num="num" color="#c95948" width='21' height='34' fontSize='34'></countup>
							<view class="danwei">元</view>
						</view>
						<view class="open_tips">已存入钱包，可直接体现</view>
					</view>
					<view class="lookbag_box">
						<view class="lookbag_btn">
							<view class="text" @click.stop="lookbagbrn()">确认</view>
						</view>
					</view>
					<view class="hide_btn" @click.stop="hideopenbtn()">
						<icon type="cancel" color="#fbd977" size="28" />
					</view>
				</view>
			</view>
			<!-- end红包 -->
			<shopro-login-modal></shopro-login-modal>


			<!-- 提示已退款 -->
			<u-mask :show="tixinFlage == 3 && firstFlage == 1" @click="tixinFlage = 0">
				<view class="tixinwarp">
					<view class="tixinrect" @tap.stop>
						<view class="title-image">
							<image src="../../../static/images/index/tixin.png" style="width: 218upx; height: 217upx;">
							</image>
						</view>
						<view class="tips">
							<view class="line left-line"></view>
							<view class="title">温馨提示</view>
							<view class="line right-line"></view>
						</view>
						<view class="tishi-content">
							你未拼中奖品，款项已原路退回
						</view>
						<view class="cancel-btn" @click="goPingtuan">我知道了</view>
					</view>
				</view>
			</u-mask>


			<!-- 没有中奖 -->
			<u-mask :show="is_zj == 2 && tixinFlage != 3 && firstFlage == 1">
				<view class="tixinwarp">
					<view class="tixinrect" @tap.stop>
						<view class="title-image">
							<image src="../../../static/images/index/tixin2.png" style="width: 218upx; height: 217upx;">
							</image>
						</view>
						<view class="tips">
							<view class="line left-line"></view>
							<view class="title">未中奖</view>
							<view class="line right-line"></view>
						</view>
						<view class="tishi-content">
							系统已自动退款
						</view>
						<view class="cancel-btn" @click="goPingtuan">确定</view>
					</view>
				</view>
			</u-mask>

			<!-- 已经中奖 -->
			<u-mask :show="is_zj == 1 && tixinFlage != 3 && firstFlage == 1">
				<view class="tixinwarp">
					<view class="tixinrect" @tap.stop>
						<view class="title-image">
							<image src="../../../static/images/index/tixin.png" style="width: 218upx; height: 217upx;">
							</image>
						</view>
						<view class="tips">
							<view class="line left-line"></view>
							<view class="title">恭喜您~</view>
							<view class="line right-line"></view>
						</view>
						<view class="tishi-content">
							拼中商品
						</view>
						<view class="cancel-btn" @click="goPingtuan">确定</view>
					</view>
				</view>
			</u-mask>


		</mescroll-body>
	</view>
</template>
<script>
	import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
	// 应用数字滚动插件
	import countup from '@/components/countUp.vue';

	import {
		mapState 
	} from 'vuex';
	let systemInfo = uni.getSystemInfoSync();
	
	import shPriceCard from './components/sh-price-card.vue';
	import shServe from './components/sh-serve.vue';
	import shGroupon from './components/sh-groupon.vue';
	import shCoupon from './components/sh-coupon.vue';
	import shComment from './components/sh-comment.vue';
	export default {
		mixins: [MescrollMixin],
		components: {
			shPriceCard,
			shServe,
			shGroupon,
			shCoupon,
			shComment,
			countup
		},
		data() {
			return {
				firstFlage: 0,
				subsidy: '',
				team_str: '',
				backIconName: 'arrow-left',
				showEmpty: false,
				showEmptyText: '',
				goodsInfo: {},
				activityRules: {},
				showSku: false, //是否显示规格弹窗
				currentSkuText: '', //选中规格
				showServe: false, // 服务弹窗
				tabCurrent: 'tab0', // 选项卡选中
				upOption: {
					auto: false
				},
				downOption: {
					auto: false
				},
				tabList: [ // 选项卡
					{
						id: 'tab0',
						title: '商品详情'
					},
					// {
					// 	id: 'tab1',
					// 	title: '规格参数'
					// },
					// {
					// 	id: 'tab2',
					// 	title: '用户评价'
					// }
				],
				commentNum: 0, //商品评价总数
				commentList: [],

				num: 0,
				bag1animation: {},
				openbrnanimation: {},
				rbagmodelshow: false,
				openrbagmodelshow: false,
				subsidylist: [],
				teammemberid: '',
				result: {},
				tixinFlage: 0,
				is_zj: 0, // 是否中奖
				countDay: 1,
			};
		},
		onShow: function() {
			// this.getGoodsInfo();
			//多次401跳转到登录页面,关闭一个
			// this.imageanimation();
			this.firstFlage += 1;
			this.downCallback();
			this.imageanimation();
			// this.downCallback();
		},
		methods: {
			// 
			goPingtuan() {
				if (this.$Route.query.teammemberid) {
					this.$Router.push({
						path: '/pages/index/collage-detail/collage-detail',
						query: {
							id: this.$Route.query.id,
							teammemberid: this.$Route.query.teammemberid
						}
					})
				} else if (this.teammemberid) {
					this.$Router.push({
						path: '/pages/index/collage-detail/collage-detail',
						query: {
							id: this.$Route.query.id,
							teammemberid: this.teammemberid
						}
					})
				}
				this.is_zj = 0;
				this.tixinFlage = 0;
			},
			// 下拉刷新列表
			downCallback() {
				this.mescroll.resetUpScroll(); // 重置列表为第一页 (自动执行 page.num=1, 再触发upCallback方法 )
			},
			/*上拉加载的回调*/
			async upCallback(page) {
				await this.getGoodsInfo();


				this.imageanimation();
				this.mescroll.endBySize(1, 0);
			},


			jump(path, query = {}, type = 0) {
				if (type === 0) {
					this.$Router.push({
						path: path,
						query: query
					});
				} else {
					this.$Router.push({
						path: path,
						query: query
					});
				}

			},
			// 组件返回的type;
			changeType(e) {
				this.buyType = e;
			},
			// 组件返回的规格;
			getSkuText(e) {
				this.currentSkuText = e;
			},
			// 补贴领取详情


			// 点击领取补贴
			subsidyAction() {
				let that = this;
				this.$http.get('index.addsubsidy', {
					team_id: this.$Route.query.id,
					team_member_id: this.$Route.query.teammemberid
				}).then(res => {
					
					that.num = res.data.price;

				}).catch(err => {
					if(this.countDay > 0){
						this.subsidyAction();
					}
					this.countDay--;
					that.hideopenbtn();
				})
			},
			// 选项卡
			onTab(id) {
				this.tabCurrent = id;
			},
			// 轮播图预览
			onGoodsSwiper(e) {
				this.$tools.previewImage(this.goodsInfo.images, e);
			},
			getActivityRules(e) {
				if (e) {
					this.activityRules = JSON.parse(e);
				}
			},
			// 检测
			checkActivity(data, type) {
				if (data) {
					return !data.includes(type);
				}
				return true;
			},
			// 组件返回的规格;
			getSkuText(e) {
				this.currentSkuText = e;
			},
			getSubsidydetail() {
				if (this.teammemberid) {

					this.$http.get('index.subsidydetail', {
						team_id: this.$Route.query.id,
						team_member_id: this.teammemberid,
					}).then(res => {
						this.result = res.data;
						this.is_zj = res.data.is_zj;
						this.tixinFlage = this.result.team.team_state;
					})
				}
			},
			// 获取详情
			async getGoodsInfo() {
				// this.$http.post('index.goods.detail', {
				// 	shopid: 82
				// }).then(res => {
				// 	this.goodsInfo = res.data;
				// 	this.goodsInfo.images.forEach((el, index) => {
				// 		this.$set(this.goodsInfo.images, index, this.$IMG_URL + el);
				// 	})
				// })
				let id = this.$Route.query.id;
				return this.$http.get('index.goodsInfoDetail', {
					i: 3,
					uuid: 0,
					mid: this.userInfo.uid,
					type: 2,
					shop_id: id,
					route: "plugin.fight-groups.frontend.controllers.team.index",
					group_id: id,
				}).then(res => {
					// console.log(JSON.stringify(res.data.has_one_group.has_one_goods));
					// debugger
					// this.subsidy = res.data.has_one_group.subsidy;
					// this.team_str= res.data.team_str;
					// this.subsidy = res.data.has_one_group.subsidy;
					// this.team_str= res.data.team_str;
					let _this = this;
					// res.data.has_many_success_member.forEach((el, index) => {
					// 	if(el.has_one_member.uid === this.userInfo.uid){
					// 		_this.teammemberid = el.team_member_id;
					// 	}
					// })
					this.goodsInfo = Object.assign({}, this.goodsInfo, res.data);
					// this.goodsInfo = res.data;
					if (this.teammemberid) {
						this.getSubsidydetail();
					}
					// this.goodsInfo = res.data;
					// this.goodsInfo.images.forEach((el, index) => {
					// 	this.$set(this.goodsInfo.images, index, this.$IMG_URL + el);
					// })
				})
			},
			concalOrder() {
				this.$http.get('user.getptuanTongji2').then(res => {

				})
			},
			// // 关闭参团未支付订
			cancelOrder() {
				return this.$http.get('user.getptuanTongji2').then(res => {

				})
			},
			// 立即购买
			goPay() {
				// this.buyType = 'buy';
				// this.showSku = true;
				// uni.showToast({
				// 	title: uni.getStorageSync('AuthToken')
				// })
				if (this.goodsInfo.is_team != 0) {
					uni.showToast({
						title: "不能重复参团",
						icon: "none"
					})
					return
				}
				if (this.goodsInfo.status === 2) {
					uni.showToast({
						title: "已成团",
						icon: "none"
					})
					return
				}
				if (this.AuthToken) {
					// this.buyType = 'buy';
					// this.showSku = true;
					this.$Router.push({
						path: "/pages/order/confirm/confirm",
						query: {
							mid: this.userInfo.uid,
							goods_id: this.goodsInfo.has_one_group.goods_id,
							team_id: this.goodsInfo.id,
							option_level_id: this.goodsInfo.has_one_group.has_many_options[0]
								.has_many_option_level[0]['id']
						}
					})
				} else {
					this.$store.commit('LOGIN_TIP', true);
				}
			},
			// 侧边红包 => 动画
			imageanimation: function() {
				var that = this;
				var next = true;
				var animation = uni.createAnimation({
					duration: 1000,
					timingFunction: 'ease',
				})
				that.bag1animation = animation
				setInterval(function() {
					if (next) {
						animation.rotate(36).step();
						next = !next;
					} else {
						animation.rotate(6).step();
						next = !next;
					}
					that.bag1animation = animation.export()
				}, 1100)
			},
			// 侧边红包 => 点击
			openrbagbtn: function() {
				this.rbagmodelshow = true;
				// 领取红包
				this.subsidyAction();
			},

			// 红包封面 => 关闭按钮
			hidebtn: function() {
				this.rbagmodelshow = false;
				this.openrbagmodelshow = false;
			},
			// 红包封面 => 開红包按钮
			openbtn: function() {
				var that = this;
				var animation = uni.createAnimation({
					duration: 1000,
					timingFunction: 'ease',
				})
				that.openbrnanimation = animation;
				// animation.rotate3d(0,1,0,360).step();
				animation.rotateY(360).step();
				that.openbrnanimation = animation.export();
				setTimeout(function() {
					that.rbagmodelshow = false;
					that.openrbagmodelshow = true;
					that.openbrnanimation = {};
				}, 1000);
				setTimeout(() => {
					that.$Router.push({
						path: '/pages/index/collage-detail/collage-detail',
						query: {
							id: that.$Route.query.id,
							teammemberid: that.$Route.query.teammemberid
						}
					})
				}, 2000);
			},

			// 打开红包  => 关闭按钮
			hideopenbtn: function() {
				this.openrbagmodelshow = false;
				this.rbagmodelshow = false;
			},
			// 打开红包  => 查看钱包
			lookbagbrn: function() {
				this.hideopenbtn();
			},

		},
		computed: {
			...mapState(['AuthToken', 'userInfo']),
			navbarHeight() {
				// #ifdef APP-PLUS || H5
				return 48;
				// #endif
				// #ifdef MP
				let height = systemInfo.platform == 'ios' ? 44 : 48;
				return height;
				// #endif
			}
		},
		async onLoad() {

			let that = this;
			await this.cancelOrder();
			// this.concalOrder();
			this.backIconName = getCurrentPages().length > 1 ? 'arrow-left' : 'home-fill';
			this.detailType = 'buy'; // score:积分商品  buy正常购买  
			// 如果从订单进来，就是支付，进行红包的领取
			if (this.$Route.query.formmethod === 'order-method') {
				this.openrbagbtn();
			}
		},

		// #ifdef MP-WEIXIN
		// 分享好友
		onShareAppMessage(res) {
			let shareInfo = {};
			shareInfo.path =
				`/pages/index/goods-detail/goods-detail?id=${this.$Route.query.id}&shareid=${this.userInfo.uid}`;
			shareInfo.image = this.goodsInfo.has_one_group.has_one_goods.thumb_url[0];
			shareInfo.title = `和我一起拼团，领${this.goodsInfo.has_one_group.subsidy}元商家补贴`;
			return {
				title: shareInfo.title,
				path: shareInfo.path,
				imageUrl: shareInfo.image,
				success(res) {
					uni.showToast({
						title: '分享成功'
					})
				},
				fail(res) {
					uni.showToast({
						title: '分享失败',
						icon: 'none'
					})
				},
				complete() {}
			}
		},

		// #endif
	}
</script>

<style scoped lang="scss">
	@import './goods-detail.scss';
</style>


<style scoped lang="scss">
	.r_bag {
		.bag1 {
			position: fixed;
			left: -46upx;
			top: 160upx;
			width: 150upx;
			height: 100upx;
			z-index: 999;
		}
	}

	// 红包封面
	.rbag_model {
		position: fixed;
		top: 0;
		left: 0;
		width: 100%;
		height: 100vh;
		background-color: rgba(0, 0, 0, 0.3);
		z-index: 1000;

		.rbag_con {
			position: absolute;
			top: 0;
			left: 0;
			right: 0;
			bottom: 0;
			width: 80%;
			height: 840upx;
			background-color: #da4d44;
			margin: auto;
			border-radius: 14upx;
			box-shadow: 0upx 0upx 10upx rgba(0, 0, 0, 0.2);

			.rbag_top {
				position: absolute;
				left: -20%;
				top: 0;
				width: 140%;
				height: 540upx;
				background-color: #e0534a;
				border-radius: 0 0 50% 50%;
				box-shadow: 0 0 14upx rgba(0, 0, 0, 0.4);
				z-index: 1001;

				.rbag_top_info {
					margin-top: 60upx;

					.rbag_logo {
						width: 160upx;
						height: 160upx;
						border-radius: 50%;
						display: block;
						margin: 0 auto;
						overflow: hidden;
					}

					.app_name {
						font-size: 38upx;
						color: #f6ac96;
						text-align: center;
						margin-top: 18upx;
						letter-spacing: 1upx;
					}

					.rbag_tips {
						font-size: 50upx;
						color: #edddd3;
						text-align: center;
						margin-top: 34upx;
						letter-spacing: 1upx;
					}
				}
			}

			.open_rbag_btn {
				position: absolute;
				top: 450upx;
				left: 0;
				right: 0;
				width: 180upx;
				height: 180upx;
				line-height: 180upx;
				border-radius: 50%;
				margin: 0 auto;
				text-align: center;
				background-color: #ffd287;
				font-size: 55upx;
				color: #fef5e8;
				box-shadow: 2upx 2upx 6upx rgba(0, 0, 0, 0.2);
				z-index: 1002;
			}

			.hide_btn {
				position: absolute;
				bottom: -110upx;
				left: 0;
				right: 0;
				width: 80upx;
				height: 80upx;
				line-height: 80upx;
				text-align: center;
				margin: 0 auto;
			}
		}

		.hidden {
			overflow: hidden;
		}
	}

	// 打开红包
	.open_rbag_model {
		position: fixed;
		top: 0;
		left: 0;
		width: 100%;
		height: 100vh;
		background-color: rgba(0, 0, 0, 0.3);
		z-index: 1000;

		.rbag_conbg {
			position: absolute;
			top: 0;
			left: 0;
			right: 0;
			bottom: 0;
			width: 80%;
			height: 840upx;
			margin: auto;
			z-index: 1001;
		}

		.open_rbag_con {
			z-index: 1002;

			.open_title {
				height: 120upx;
				line-height: 120upx;
				text-align: center;
				font-size: 38upx;
				letter-spacing: 2upx;
				color: #e46965;
			}

			.rbag_detail {
				margin-top: 90upx;

				.open_money {
					text-align: center;
					font-size: 80upx;
					color: #c95948;
					font-weight: bold;
					display: flex;
					justify-content: center;

					.danwei {
						font-size: 30upx;
						margin-left: 16upx;
						margin-top: 24upx;
					}
				}

				.open_tips {
					text-align: center;
					font-size: 30upx;
					color: #d26762;
					margin-top: 30upx;
				}
			}

			.lookbag_box {
				margin-top: 200upx;
				display: flex;
				justify-content: center;

				.lookbag_btn {
					width: 70%;
					height: 90upx;
					line-height: 90upx;
					text-align: center;
					font-size: 32upx;
					color: #c95948;
					letter-spacing: 2upx;
					background-color: #ffd356;
					border-radius: 50upx;
					box-shadow: 0upx 0upx 4upx rgba(0, 0, 0, 0.2);
				}
			}

			.hide_btn {
				position: absolute;
				bottom: -110upx;
				left: 0;
				right: 0;
				width: 80upx;
				height: 80upx;
				line-height: 80upx;
				text-align: center;
				margin: 0 auto;
			}
		}
	}
</style>


<style scoped lang="scss">
	.tixinwarp {
		display: flex;
		align-items: center;
		justify-content: center;
		height: 100%;
	}

	.tixinrect {
		width: 530upx;
		height: 450upx;
		background: #FFFFFF;
		border-radius: 10upx;

		.title-image {
			width: 217upx;
			height: 217upx;
			margin: 0 auto;
			margin-top: -110upx;
		}

		.tips {
			display: flex;
			align-content: center;
			justify-content: space-between;
			margin-top: 5upx;
			padding: 0 50upx;

			.line {
				width: 123upx;
				height: 1upx;
				background: #E5E5E5;
				margin-top: 17upx;
			}

			.title {
				font-size: 26upx;
				color: #000000;
				font-weight: bold;
			}
		}

		.tishi-content {
			font-size: 24upx;
			color: #6E6D6D;
			padding: 0 60upx;
			margin-top: 50upx;
			text-align: center;
		}

		.cancel-btn {
			width: 461upx;
			height: 65upx;
			background: #FF6027;
			border-radius: 33upx;
			text-align: center;
			line-height: 65upx;
			color: #FFFFFF;
			font-size: 28upx;
			margin: 0 auto;
			margin-top: 50upx;
		}
	}
</style>
